package com.project.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.TopicBean;
import com.project.mapper.ITopicMapper;
import com.project.service.ITopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service
@Transactional
public class TopicServiceImpl implements ITopicService {
    @Autowired
    private ITopicMapper topicMapper;

    @Override
    public PageInfo<TopicBean> findByItem(int channelId, int pageNO,
                                          String name, String userName, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNO,PAGE_SIZE);
        PageInfo<TopicBean> info = PageInfo.of(topicMapper.findByItem(channelId,name,userName,startDate,endDate));

        return info;
    }

    @Override
    public void add(TopicBean topic) {
        topicMapper.add(topic);
    }

    @Override
    public TopicBean findById(int id) {
        return topicMapper.findById(id);
    }
}
